<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./css/bootstrap.css">
</head>
<body>
<?php
require_once "./conn.php";
if (count($_POST)>0) {
    mysqli_query($link,"UPDATE users set name='" . $_POST['username'] . "',
    mobile='" . $_POST['mobile'] . "' ,email='" . $_POST['email'] . "' WHERE id='" .$_POST['id'] . "'");
    header("location: index.php");
    exit();    
}
$id=$_GET['id'];

$sql="select * from users where id = '".$id."'";
$result = mysqli_query($link,$sql);
$row=mysqli_fetch_array($result);
//var_dump($row);
?>
    <div class="container">
        <div class="row justify-content-start" >
            <div class="col-sm-6">
                <h1>修改数据</h1>
                <form method="POST" action="./update.php">
                    <div class="form-group">
                        <label for="username">姓 名</label>
                        <input type="type" class="form-control" id="username" name="username" value="<?php echo $row['name'];?>">
                    </div>
                    <div class="form-group">
                        <label for="email">邮 箱</label>
                        <input type="type" class="form-control" id="email" name="email" value="<?php echo $row['email'];?>" >
                    </div>
                    <div class="form-group">
                        <label for="mobile">电话号码</label>
                        <input type="type" class="form-control" id="mobile" name="mobile" value="<?php echo $row['mobile'];?>" >
                    </div>
                    <input type="hidden" name="id" value="<?php echo $row["id"];?>"/>
                    <button type="submit" class="btn btn-primary" name="update">修改</button>
                    <a href="./index.php" class="btn btn-success">返回</a> 
                  </form>
            </div>
        </div>
    </div>
</body>
</html>